from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
import os, time

# 鼠标事件
chromedriver = "C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe"  # 浏览器驱动位置
os.environ["webdriver.chrome.driver"] = chromedriver
driver = webdriver.Chrome(chromedriver)
driver.get('http://www.baidu.com')
input1 = driver.find_element_by_id("kw")
# 鼠标右键
# ActionChains(driver).context_click(input1).perform()
tj = driver.find_element_by_link_text("设置")
# 鼠标悬停
# ActionChains(driver).move_to_element(tj).perform()

# 鼠标双击
# input1.send_keys('lcm')
# ActionChains(driver).double_click(input1).perform()

# 拖放  这个没看明白
# ActionChains(driver).drag_and_drop(tj, input1).perform()

input1.send_keys("seleniummm")
# 退格
input1.send_keys(Keys.BACK_SPACE)
# 空格  还有很多组合键 自己查
input1.send_keys(Keys.SPACE)
# 当前标题
print(driver.title)
# URL
print(driver.current_url)
time.sleep(2)
driver.quit()
